package com.huangliusong;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;

/**
 * 输出内容到文件
 * @author huangliusong
 * @since 2019/1/21
 * {@link }
 */
public class FileOut {
    public static void main(String[] args) throws IOException, InterruptedException {
        System.out.println("start output file");

        String fileContent="file content!\nhuangliusong";
        String fileName="/Users/liusonghuang/Downloads/logstash-tutorial.log";
        File file=new File(fileName);
        if (!file.exists()){
            file.createNewFile();
        }

        FileOutputStream fileOutputStream=new FileOutputStream(file);
        fileOutputStream.write(fileContent.getBytes());

        fileOutputStream.close();

        for (int i=0;i<100;i++){
            Thread.sleep(1000);
            System.out.println("xiaowu  "+1+"  "+new Date());
        }

    }
}
